
#pragma once

#include <rviz_common/display.hpp>

#include <memory>

#include <rviz_common/properties/color_property.hpp>
#include <rviz_common/properties/enum_property.hpp>
#include <rviz_common/properties/float_property.hpp>
#include <rviz_common/properties/int_property.hpp>
#include <rviz_common/properties/tf_frame_property.hpp>
#include <rviz_common/properties/vector_property.hpp>
#include <rviz_default_plugins/visibility_control.hpp>

using rviz_common::Display;

namespace rviz_rendering
{
    class Grid;
}

namespace rviz_custom_plugins {

namespace displays {

class RVIZ_DEFAULT_PLUGINS_PUBLIC CustomGridDisplay : public Display
{
    Q_OBJECT

public:
    enum Plane
    {
        XY,
        XZ,
        YZ,
    };

    CustomGridDisplay();
    ~CustomGridDisplay() override;

    // Overrides from Display
    void onInitialize() override;
    void update(float dt, float ros_dt) override;
    void setStatus(rviz_common::properties::StatusProperty::Level level, const QString & name, const QString & text) override;

private Q_SLOTS:
    void updateCellSize();
    void updateColor();
    void updatePlane();

private:
    std::unique_ptr<rviz_rendering::Grid> grid_;  ///< Handles actually drawing the grid

    rviz_common::properties::TfFrameProperty * frame_property_;
    rviz_common::properties::FloatProperty * cell_size_property_;
    rviz_common::properties::ColorProperty * color_property_;
    rviz_common::properties::FloatProperty * alpha_property_;
    rviz_common::properties::EnumProperty * plane_property_;
};

}

}
